<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">搜索github网站上的用户</h3>
    <div>
      <input
        type="text"
        placeholder="请输入关键字"
				v-model="keyword"
      />&nbsp;
			<button @click="handleSearch">搜索</button>
    </div>
  </section>
</template>

<script>
import axios from 'axios'

export default {
  name: "Search",
	data() {
		return {
			keyword:''
		}
	},
	methods: {
		handleSearch(){
			//发请求获取数据，打印一下看看
			axios.get(`https://api.github.com/search/users?q=${this.keyword}`).then(
				response => {
					// console.log(response.data)
					this.$bus.$emit('get-users',response.data.items)
				},
				error => {
					console.log(error.message)
				}
			)
		}
	},
};
</script>